package org.springframework.liukai.test.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * @author liukai
 * @description TODO
 * @date 2022/7/17 12:02
 */
//@Component
public class MyInstantiationAwareBeanPostProcessor2 implements InstantiationAwareBeanPostProcessor, Ordered {
	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		if (beanClass == Person.class) {
			Person person = new Person();
			person.setId(1);
			person.setName("MyInstantiationAwareBeanPostProcessor2");
			return person;
		}
		return null;
	}

	@Override
	public int getOrder() {
		return 10;
	}
}
